package car.aistar.service.impl;

import car.aistar.dao.UserRecordsDao;
import car.aistar.entity.UserRecords;
import car.aistar.service.UserRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (UserRecords)表服务实现类
 *
 * @author makejava
 * @since 2020-09-30 20:58:04
 */
@Service("userRecordsService")
public class UserRecordsServiceImpl implements UserRecordsService {
    @Autowired
    private UserRecordsDao userRecordsDao;


    @Override
    public List<UserRecords> queryAll(UserRecords userRecords) {

        return this.userRecordsDao.queryAll(userRecords);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserRecords queryById(Long id) {
        return this.userRecordsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<UserRecords> queryAllByLimit(int offset, int limit) {
        return this.userRecordsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userRecords 实例对象
     * @return 实例对象
     */
    @Override
    public UserRecords insert(UserRecords userRecords) {
        this.userRecordsDao.insert(userRecords);
        return userRecords;
    }

    /**
     * 修改数据
     *
     * @param userRecords 实例对象
     * @return 实例对象
     */
    @Override
    public UserRecords update(UserRecords userRecords) {
        this.userRecordsDao.update(userRecords);
        return this.queryById(userRecords.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.userRecordsDao.deleteById(id) > 0;
    }

    /**
    *@Author laoxu
    *@Description //TODO 用户浏览记录删除
    *@Date 7:54 2020/10/5
    *@Param [uid, cid]
    *@return boolean
    **/
    @Override
    public boolean deleteById1(Long uid, Long cid) {
        return this.userRecordsDao.deleteById1(uid,cid) > 0;
    }
}